package jh.com.jhappbf.fragmentactivity;

import android.content.Intent;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

import jh.com.jhappbf.R;
import jh.com.jhappbf.ui.AssayDetail;
import jh.com.jhappbf.ui.AssayFragment;
import jh.com.jhappbf.ui.CargoNameFragment;

/**
 * @author Administrator
 */
public class MyFragmentActivity extends SingleFragmentActivity {

    @Override
    public Fragment createFragment() {
        Intent intent = getIntent();
        String flagString = intent.getStringExtra("flag");
        Fragment mFragment = null;
        switch (flagString) {
            case "assay":
                mFragment = new AssayFragment();
                break;
            case "assayDetail":
                mFragment = new AssayDetail();
                break;
            case "cargoName":
                mFragment = new CargoNameFragment();
                break;
            default:
        }
        return mFragment;
    }

    @Override
    protected void onActivityResult(int arg0, int arg1, Intent arg2) {
        super.onActivityResult(arg0, arg1, arg2);
        FragmentManager fm = getSupportFragmentManager();
        Fragment f = fm.findFragmentById(R.id.ui_singleActivity_frame);
        if (f != null) {
            f.onActivityResult(arg0, arg1, arg2);
        }
    }
}
